from fractions import Fraction
import math

n = int(input())
f = [False for i in range(n + 2)]
s = ' ' + input()
for i in range(1,n + 1):
    f[i] = (s[i] == '1')
cnt = [0 for i in range(n + 2)]
for i in range(n,0,-1):
    cnt[i] = cnt[i + 1] + f[i]
dp = [[Fraction(0) for i in range(n + 2)] for j in range(n + 2)]
dp1 = [[Fraction(0) for i in range(n + 2)] for j in range(n + 2)]
dp1[1][cnt[1]] = Fraction(1)
cost = 1 / Fraction(n - cnt[1])
for i in range(1,n + 1):
    # print(cnt[i],n - i + 2)
    for j in range(cnt[i],min(n - i + 2,cnt[1] + 1)):
        if f[i]:
            dp1[i + 1][j] += (dp1[i][j])*Fraction(n - i - (j - 1))/Fraction(n - cnt[1]) 
            dp[i + 1][j] += (dp[i][j] + (cost + 1)*dp1[i][j])*Fraction(n - i - (j - 1))/Fraction(n - cnt[1])
            dp1[i + 1][j - 1] += (dp1[i][j])*Fraction(i - 1 - (cnt[1] - j))/Fraction(n - cnt[1]) 
            dp[i + 1][j - 1] += (dp[i][j] + (cost + 1)*dp1[i][j])*Fraction(i - 1 - (cnt[1] - j))/Fraction(n - cnt[1])
        else:
            p1 = Fraction(math.comb(n - i - cnt[i],j - cnt[i]))/Fraction(math.comb(n - i + 1 - cnt[i],j - cnt[i]))
            p2 = 1 - p1
            dp1[i + 1][j] += dp1[i][j]*p1
            dp[i + 1][j] += dp[i][j]*p1
            dp1[i + 1][j] += dp1[i][j]*p2*Fraction(n - i - (j - 1))/Fraction(n - cnt[1]) 
            dp[i + 1][j] += (dp[i][j]*p2 + (cost + 1)*dp1[i][j]*p2)*Fraction(n - i - (j - 1))/Fraction(n - cnt[1])
            dp1[i + 1][j - 1] += dp1[i][j]*p2*Fraction(i - 1 - (cnt[1] - j))/Fraction(n - cnt[1]) 
            dp[i + 1][j - 1] += (dp[i][j]*p2 + (cost + 1)*dp1[i][j]*p2)*Fraction(i - 1 - (cnt[1] - j))/Fraction(n - cnt[1])
print(dp[n + 1][0])
MOD = int(1e9+7)
def qpow(x,p):
    res = 1
    while p:
        if p & 1:
           res = res*x%MOD
        x = x*x%MOD
        p >>= 1
    return res 
print(dp[n + 1][0].numerator%MOD*qpow(dp[n + 1][0].denominator,MOD - 2)%MOD)